package com.djz.stuinfomge.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class SystemArchitecture {
    //中间的模块使用通配符替代
    @Pointcut("within(com.djz.stuinfomge.web..*)")
    public void inWebLayer() {
    }

    /**
     * A join point is in the service layer if the method is defined in a type
     * in the com.huisou.alliance.ad.service package or any sub-package under that.
     */
    @Pointcut("within(com.djz.stuinfomge.service..*)")
    public void inServiceLayer() {
    }

    @Pointcut("execution(* com.djz.stuinfomge.service.*.*(..))")
    public void businessService() {
    }

    @Pointcut("within(com.djz.stuinfomge..*)")
    public void allMethod() {
    }
    /**用于测试，项目完成后，注释掉*/
    @Around("com.djz.stuinfomge.aop.SystemArchitecture.businessService()")
    public Object log(ProceedingJoinPoint pjp) throws Throwable {
	
	String clName = pjp.getTarget().getClass().getName();
	String mName = pjp.getSignature().getName();
	String clM = clName+"  "+ mName;
	System.out.println("进入方法："+ clM);
	Object retVal = pjp.proceed();
	System.out.println("退出方法："+ clM);
	return retVal;
    }

  

    private Logger logger = LoggerFactory.getLogger(getClass());
}
